#!/bin/sh
RESOURCE_NAME="springboot.jar"

SERVICE_PID=`ps -ef|grep ${RESOURCE_NAME}|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${SERVICE_PID} ]; then
echo 'Stop Process...'
kill -15 ${SERVICE_PID}
fi
sleep 5
SERVICE_PID=`ps -ef|grep ${RESOURCE_NAME}|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${SERVICE_PID} ]; then
echo 'Kill Process!'
kill -9 ${SERVICE_PID}
else
echo 'Stop Success!'
fi
 
SERVICE_PID=`ps -ef|grep ${RESOURCE_NAME}|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${SERVICE_PID} ]; then
    echo 'App is running, App Stop Success!'
else
    echo 'App is NOT running, App Stop Success!'
fi
 
rm -f ${SERVICE_PID}
nohup java -jar ./${RESOURCE_NAME} > log/null 2>&1 &
#nohup java -jar ./${RESOURCE_NAME} > log/springboot.log 2>&1 &
echo 'Start Success!'